package org.kabeja.parser.entities;

import org.kabeja.dxf.entity.DXFEllipse;
import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 11:23
 */
public class DXFEllipseHandler extends AbstractEntityHandler {
    public static final String ENTITY_NAME = "ELLIPSE";
    public static final int RATIO = 40;
    public static final int START_PARAMETER = 41;
    public static final int END_PARAMTER = 42;
    public static final int COUNTERCLOCKWISE = 73;
    private DXFEllipse ellipse;

    public DXFEllipseHandler() {
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.ellipse;
    }

    @Override
    public String getDXFEntityName() {
        return "ELLIPSE";
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 10:
                this.ellipse.getCenterPoint().setX(var2.getDoubleValue());
                break;
            case 11:
                this.ellipse.getMajorAxisDirection().setX(var2.getDoubleValue());
                break;
            case 20:
                this.ellipse.getCenterPoint().setY(var2.getDoubleValue());
                break;
            case 21:
                this.ellipse.getMajorAxisDirection().setY(var2.getDoubleValue());
                break;
            case 30:
                this.ellipse.getCenterPoint().setZ(var2.getDoubleValue());
                break;
            case 31:
                this.ellipse.getMajorAxisDirection().setZ(var2.getDoubleValue());
                break;
            case 40:
                this.ellipse.setRatio(var2.getDoubleValue());
                break;
            case 41:
                this.ellipse.setStartParameter(var2.getDoubleValue());
                break;
            case 42:
                this.ellipse.setEndParameter(var2.getDoubleValue());
                break;
            case 73:
                this.ellipse.setCounterClockwise(var2.getBooleanValue());
                break;
            default:
                super.parseCommonProperty(var1, var2, this.ellipse);
        }

    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.ellipse);
    }

    @Override
    public void startDXFEntity() {
        this.ellipse = new DXFEllipse();
        this.ellipse.setDXFDocument(this.doc);
    }
}
